package fr.afcepf.atod19.voyage.test;

import java.math.BigDecimal;
import java.util.List;

import javax.inject.Inject;

import junit.framework.Assert;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import fr.afcepf.atod19.voyage.entities.Voyage;
import fr.afcepf.atod19.voyage.facade.FacadeAdminGestionVoyage;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/springContext.xml" })
public class TestServiceVoyage {

	/*@Inject
	FacadeAdminGestionVoyage facadeAdminVoyage;

	@Test
	public void testCreerUnVoyage() {
		Voyage v = new Voyage();

		v.setDepart("TestDepart");
		v.setDestination("TestDestination");
		v.setDateDepart("01/12/2014");
		v.setDateRetour("31/12/2014");
		v.setNbrePlace(30);
		BigDecimal x = new BigDecimal(1000);
		v.setPrix(x);
		
		facadeAdminVoyage.creerUnVoyage(v);
		
		Voyage vRech = new Voyage();
		
		vRech.setDestination("TestDestination");
		
		List<Voyage> lv = facadeAdminVoyage.rechercherVoyage(vRech);

		Assert.assertNotNull(lv);
		Assert.assertTrue(lv.size() > 0);

	}

	@Test
	public void rechercherVoyage() {

		Voyage v = new Voyage();

		v.setDepart("TestDepart");
		v.setDestination("TestDestination");

		List<Voyage> lv = facadeAdminVoyage.rechercherVoyage(v);
		Assert.assertNotNull(lv);
		Assert.assertTrue(lv.size() > 0);
	}

	@Test
	public void testConsulterUnVoyage() {
		Voyage v = facadeAdminVoyage.consulterUnVoyage(1);

		Assert.assertNotNull(v);
		Assert.assertTrue(v.getIdVoyage() != 0);
		System.out.println("Test " + v.getReference());
	}

	//@Test
	public void testSupprimerUnVoyage(){
		Voyage v1 = new Voyage(); 
		v1.setDepart("TestDepart");
		v1.setDateRetour("TestDestination");
		Assert.assertNotNull(facadeAdminVoyage.rechercherVoyage(v1));
		System.out.println(facadeAdminVoyage.rechercherVoyage(v1).size());
		Voyage v2 = facadeAdminVoyage.rechercherVoyage(v1).get(0);
		Assert.assertNotNull(v2);
		System.out.println("voyage v2 " + v2.getIdVoyage());
		Boolean b = facadeAdminVoyage.supprimerUnVoyage(v2);
		System.out.println("C'est moi qui t'emmerde " + b);
		Assert.assertTrue(b);
	}*/
}
